{* $Id$ *}
{include_core file="admin/lib/header.html" title="封神传奇海报管理"}
<div class="page-header border-bottom clearfix">
    <h2 class="left">封神传奇海报管理<span></span></h2>
</div>


<div class="search-form js_advancedForm">
    <form action="fengshen/admin" method="get" class="js_focusSearchForm">
        <input type="hidden" name="is_advenced" value="1">

            <label for="" class="search-f-label">合伙人姓名：</label>
            <input type="text" class="search-f-ipt1" name="search_filter[dealer_name]" value="{$search_filter.dealer_name}">
        </p>
        <p>
            <label for="" class="search-f-label">门店名称(前缀)：</label>
            <input type="text" class="search-f-ipt1" name="search_filter[title]" value="{$search_filter.title}">
        </p>

        <p>
            <label for="" class="search-f-label">掌柜姓名：</label>
            <input type="text" class="search-f-ipt1" name="search_filter[realname]" value="{$search_filter.realname}">
        </p>
        <p>
            <label for="" class="search-f-label">掌柜手机号：</label>
            <input type="text" class="search-f-ipt1" name="search_filter[mobile]" value="{$search_filter.mobile}">
        </p>
        <p>
            <label for="" class="search-f-label">地区筛选：</label>
            <select name="search_filter[province_id]" class="js_provinceList" style="width:120px;">
                <option value="0" selected="selected">请选择省份</option>
            </select>
        </p>

        <p><label for="" class="search-f-label"></label><button type="submit" class="btn btn-success btn-xs js_searchBtn">搜索</button></p>
    </form>
</div>

<!--start:列表-->
<table class="list-table">
    <thead><tr>
        <th style="min-width:60px;">任务照片</th>
        <th style="min-width:60px;">合伙人姓名</th>
        <th style="min-width:200px;">店铺信息</th>
        <th style="min-width:60px;">上传时间</th>
        <th style="min-width:60px;">状态</th>
        <th style="width:60px;">操作</th>
    </tr></thead>
    <tbody>
    {foreach $list as $k=>$v}

    <tr id="dataList{$v.id}" {if $k%2 == 1} class="bg-gray"{/if} data-id="{$v.id}">

    <td>
        <a href="{if $v['src']}{_image($v['src'])}{else}{store_helper::cover($v['src'])}{/if}" target="_blank"><img width="100" src="{if $v['src']}{_image($v['src'])}{else}{store_helper::cover($v['src'])}{/if}" /></a>
    </td>

    <td>{$v.parent_id}</td>
    <td>
        店铺名称：{$v.store_id}{$v.title_branch}<br/>
        店长手机号：{$v.mobile}<br/>
        合伙人：{$v.dealer_name}<br/>
        合伙人手机号：{$v.dealer_mobile}<br/>
        店铺地址：{$v.address}
    </td>
    <td>{time_format($v.upload_time)}</td>
    <td>
        {if $v.status == 1}
        <span class="label label-danger">失败</span>
        <!-- <a href="{AnUrl("store/admin/recover_store?id={$v.id}")}" class="btn btn-warning btn-xs"><i class="icon-trash icon-white"></i>未审核</a> -->
        {elseif $v.status == 2}
        <span class="label label-success">通过</span>
        <!-- <a href="javascript:void(0);" class="btn btn-success btn-xs"><i class="icon-trash icon-white"></i>正常</a> -->
        {else}
        <span class="label label-warning">未审核</span>
        <!-- <a href="javascript:void(0);" class="btn btn-danger btn-xs"><i class="icon-trash icon-white"></i>撤店</a> -->
        {/if}
    </td>

    <td>
        {if $v.status == 0}
        <a href="{AnUrl("store/admin/recover_store?id={$v.id}&is_delete=$is_delete")}" class="btn btn-warning btn-xs"><i class="icon-trash icon-white"></i>审核通过</a>
        {/if}
    </td>


    </tr>

    {/foreach}
    </tbody>

</table>
<script type="text/javascript">

    //初始化省份列表
    $.ajax({
        url : 'area/admin/ajax_get_provinces',
        type : 'get',
        dataType : 'json',
        success : function(province_list){
            for (var i in province_list) {
                var opt = $('<option value="'+province_list[i]['area_code']+'">'+province_list[i]['area']+'</option>');
                $('.js_provinceList').append(opt);
            }

            {if $area['province_info']}
            $('.js_provinceList').val("{$area['province_info']['area_code']}");
            //触发请求
            $('.js_provinceList').change();
            {/if}

        }
    });




    $(function(){
        $('.js_provinceList').change(function(){
            //获取值
            if($(this).val() !== '0'){
                var province = $(this).val();
                $('.js_cityList').slideDown();
                $('.js_cityList').val('0');
                $('.js_countyList').slideUp();
                $('.js_countyList').val('0');
            }else{
                $('.js_cityList').slideUp();
                $('.js_countyList').slideUp();
                $('.js_countyList').val('0');
                $('.js_cityList').val('0');
                return false;
            }
            $('.js_cityList').empty();
            $('.js_cityList').append('<option value="0">请选择城市</option>');
            $('.js_countyList').empty();
            $('.js_countyList').append('<option value="0">请选择区(县)</option>');

            //发送ajax
            $.ajax({
                url : 'area/admin/ajax_get_citys?province_code='+province,
                success : function(city_list){
                    for (var i in city_list) {
                        var opt = $('<option value="'+city_list[i]['area_code']+'">'+city_list[i]['area']+'</option>');
                        $('.js_cityList').append(opt);
                    }

                    {if $area.city_info}
                    $('.js_cityList').val("{$area.city_info.area_code}");
                    {/if}
                },
                type : 'get',
                dataType : 'json',
                async : false,
            });


        });

        // 声明一个字段映射
        var field_mapping = new Array();

        field_mapping['id'] = '店铺id';
        field_mapping['user_name'] = '分店店长';
        field_mapping['owner_name'] = '总店店长';
        /* field_mapping['agency_name'] = '合伙人';
         field_mapping['marketing_name'] = '市场人员'; */
        field_mapping['type'] = '掌柜门店类型';
        field_mapping['store_title'] = '掌柜门店名称';
        field_mapping['cover'] = '门头图';
        field_mapping['store_order'] = '分店序号';
        field_mapping['address'] = '掌柜门店地址';
        field_mapping['score'] = '掌柜门店积分';
        field_mapping['level'] = '掌柜门店等级';
        field_mapping['sign_user_name'] = '签约人员';
        field_mapping['sign_user_mobile'] = '签约人员的手机号';
        field_mapping['sign_time'] = '签约时间';



        // 将指定的元素设置为可视区域居中
        function center_format(obj){
            // 获取可是窗口的宽度
            var winWidth  = $(window).width();
            var winHeight = $(window).height();

            // 计算窗体本身的宽和高
            var objWidth = obj.width();
            var objHeight = obj.height();

            // 设置窗体的位置
            obj.css('position', 'fixed');
            // 计算left和top值
            var objLeft = (winWidth - objWidth)/2;
            // var objTop = (winHeight - objHeight)/3; // 如果除以2感觉不是垂直居中
            obj.css('left', objLeft+'px');
            obj.css('top', '20px');

        }

        // 高级搜索
        $('.js_advanced').click(function(e){
            e.preventDefault();
            var thisObj = $(this);
            var outBox  = thisObj.closest('form');
            if (thisObj.hasClass('js_isOpen')) {
                thisObj.removeClass('js_isOpen open');
                outBox.find('input').show();
                outBox.find('button').show();
                $('.js_advancedForm').hide();
            } else {
                thisObj.addClass('js_isOpen open');
                outBox.find('input').hide();
                outBox.find('button').hide();
                $('.js_advancedForm').show();
            }
        });

        // 查看掌柜门店设备信息
        $('.js_storeDevice').click(function(){
            // 获取此掌柜门店的id
            var url = $(this).attr('url');
            var th = $(this);
            // 发送ajax查询掌柜门店信息
            $.ajax({
                url : url,
                type : "get",
                dataType : 'json',
                error : function (res) {
                    showMsg('暂无设备绑定记录!');
                },
                success : function(res){

                    if (res != 'no') {
                        var infoList = res;
                        $('.float-bg').show();
                        var list = $('.js_secondDealerList').clone(true, true);

                        list.find('.js_dealerTitle').html('设备信息');
                        var head = $('<tr><th style="width:200px;text-align:center;border:1px solid #ccc">设备类型</th><th style="width:200px;text-align:center;border:1px solid #ccc">设备序列号</th><th style="width:200px;text-align:center;border:1px solid #ccc">绑定状态</th></tr>');
                        list.find('.js_expressTable').append(head);
                        $('body').append(list);
                        list.find('.js_verifySuccess').hide();


                        // 设置弹窗的位置
                        center_format(list);
                        list.show();

                        // 说明 存在掌柜门店信息

                        var str = '<tr>';
                        str += '<td style="width:200px;text-align:center;border:1px solid #ccc">一代保温箱</td>';
                        str += '<td style="width:200px;text-align:center;border:1px solid #ccc">'+infoList['old_machine']['device_no']+'</td>';
                        str += '<td style="width:200px;text-align:center;border:1px solid #ccc">'+device_status_arr[infoList['old_machine']['status']]+'</td></tr><tr>';
                        str += '<td style="width:200px;text-align:center;border:1px solid #ccc">二代保温箱</td>';
                        str += '<td style="width:200px;text-align:center;border:1px solid #ccc">'+infoList['machine']['device_no']+'</td>';
                        str += '<td style="width:200px;text-align:center;border:1px solid #ccc">'+device_status_arr[infoList['machine']['status']]+'</td></tr><tr>';
                        str += '<td style="width:200px;text-align:center;border:1px solid #ccc">广告机</td>';
                        str += '<td style="width:200px;text-align:center;border:1px solid #ccc">'+infoList['adbox']['device_no']+'</td>';
                        str += '<td style="width:200px;text-align:center;border:1px solid #ccc">'+device_status_arr[infoList['adbox']['status']]+'</td>';
                        str += '</tr>';
                        var info = $(str);
                        list.find('.js_expressTable').append(info);


                        list.find('.js_closeDealerList').click(function(){
                            list.hide();
                            list.remove();
                            $('.float-bg').hide();
                        });

                    } else {
                        showMsg('此{if $is_delete==0}回收{/if}掌柜门店下暂无设备!');
                    }
                }
            });

            return false;
        });


    });
</script>
<div class="float-confirm js_secondDealerList" style="z-index: 20000;display: none; width:auto; height:auto; margin:0px; position : fixed;">
    <div class="float-confirm-con" style="margin:0px 0px; overflow:scroll;">
        <a class="icon-close js_closeDealerList" href="javascript:void(0);">关闭</a>
        <p style="font-size:18px;color:#23a18b;" class="js_dealerTitle">{if $is_delete==0}回收{/if}掌柜门店审核</p>
        <div style="width:auto;height:1px;background:#CCC;margin-bottom:20px;"></div>
        <div style="width:500px;max-height:400px;over-flow:hidden;margin-bottom:15px;">
            <table style="line-height:50px;border:1px solid #ccc;margin:0 auto;" class="js_expressTable">
                <!-- <tr>
                  <th style="width:200px;text-align:center;border:1px solid #ccc">用户名</th>
                  <th style="width:200px;text-align:center;border:1px solid #ccc">手机号码</th>
                </tr> -->

            </table>
            <table style="line-height:50px;width:100%;line-height:24px;margin:0 auto; padding-left:20px;" class="js_refundTable">
                <tr>
                    <td rolspan="2" style="text-align:center; padding-right:20px;" ><a href="javascript:;" class="btn btn-success right js_verifySuccess" style="width:50%;;margin:20px auto;"><i class="icon-trash icon-white"></i>审核通过</a></td>
                </tr>
            </table>
        </div>
    </div>
</div>
<div class="float-bg" style="z-index: 19999; display: none"></div>
{include_core file="admin/lib/pager.html"}
<!--end:列表-->
{load_js file='zclip/jquery.zclip.min.js'}
{load_js file='zclip/ZeroClipboard.js'}
{include_core file="admin/lib/footer.html"}